
<template>
	<view>
		<!-- 控件列表 -->
		<view>
			<!-- 输入框 -->
			<view>
				<!-- 单行 -->
				<view v-if="item.__config__.jnpfKey == 'comInput' || item.__config__.jnpfKey == 'numInput'">
					<comInput v-model="formData[item.__vModel__]" :disabled="item.disabled" :type="item.__config__.jnpfKey" :maxlength='item.maxlength==null?controlProerty.maxlength:item.maxlength'
					 :placeholder="item.placeholder" :required='item.__config__.required' :showLabel='item.__config__.showLabel'
					 :label='item.__config__.label'></comInput>
				</view>

				<!-- 多行 -->
				<view v-if="item.__config__.jnpfKey == 'textarea'">
					<ymTextarea v-model='formData[item.__vModel__]' :disabled="item.disabled" :type="item.__config__.jnpfKey"
					 :placeholder="item.placeholder" :maxlength='item.maxlength==null?controlProerty.maxlength:item.maxlength'
					 :required='item.__config__.required' :showLabel='item.__config__.showLabel' :label='item.__config__.label'></ymTextarea>
				</view>
			</view>



			<!-- 公司,部门,用户,岗位树组件 -->
			<view v-if="item.__config__.jnpfKey == 'comSelect' || item.__config__.jnpfKey == 'depSelect' || item.__config__.jnpfKey == 'userSelect' || item.__config__.jnpfKey == 'posSelect'">

				<!-- 公司 -->
				<view v-if="item.__config__.jnpfKey == 'comSelect'">
					<comSelect v-model="formData[item.__vModel__]" :showLabel='item.__config__.showLabel' :placeholder="item.placeholder"
					 :label='item.__config__.label' :required='item.__config__.required' :disabled="item.disabled" :jnpfKey='item.__config__.jnpfKey'
					 :vModel='item.__vModel__' :defaultValue='item.__config__.defaultValue'></comSelect>
				</view>

				<!-- 部门 -->
				<view v-if="item.__config__.jnpfKey == 'depSelect'">
					<depSelect v-model="formData[item.__vModel__]" :showLabel='item.__config__.showLabel' :placeholder="item.placeholder"
					 :label='item.__config__.label' :required='item.__config__.required' :disabled="item.disabled" :jnpfKey='item.__config__.jnpfKey'
					 :vModel='item.__vModel__'></depSelect>
				</view>

				<!-- 用户 -->
				<view v-if="item.__config__.jnpfKey == 'userSelect'">
					<userSelect v-model="formData[item.__vModel__]" :showLabel='item.__config__.showLabel' :placeholder="item.placeholder"
					 :label='item.__config__.label' :required='item.__config__.required' :disabled="item.disabled" :jnpfKey='item.__config__.jnpfKey'
					 :vModel='item.__vModel__'></userSelect>
				</view>

				<!-- 岗位 -->
				<view v-if="item.__config__.jnpfKey == 'posSelect'">
					<posSelect v-model="formData[item.__vModel__]" :showLabel='item.__config__.showLabel' :placeholder="item.placeholder"
					 :label='item.__config__.label' :required='item.__config__.required' :disabled="item.disabled" :jnpfKey='item.__config__.jnpfKey'
					 :vModel='item.__vModel__'></posSelect>
				</view>

			</view>




			<!-- 选择框 -->
			<view v-if="item.__config__.jnpfKey == 'checkbox' || item.__config__.jnpfKey == 'radio' || item.__config__.jnpfKey == 'select'">
				<staticSelect v-model="formData[item.__vModel__]" :jnpfKey='item.__config__.jnpfKey' :label='item.__config__.label'
				 :vModel='item.__vModel__' :dataType='item.__config__.dataType' :disabled="item.disabled" :options='options'
				 :required='item.__config__.required' :showLabel='item.__config__.showLabel' :placeholder="item.placeholder"
				 :propsLabel='item.__config__.props.label' :propsValue='item.__config__.props.value' :dictionaryType='item.__config__.dictionaryType' :isId='isId' :propsAll='item.__config__.props'></staticSelect>
			</view>

			<!-- 日期时间选择 -->
			<view v-if="item.__config__.jnpfKey == 'date' || item.__config__.jnpfKey == 'time'">
				<dateTime v-model="formData[item.__vModel__]" :jnpfKey='item.__config__.jnpfKey' :label='item.__config__.label'
				 :vModel='item.__vModel__' :disabled="item.disabled" :required='item.__config__.required' :showLabel='item.__config__.showLabel'
				 :placeholder="item.placeholder"></dateTime>
			</view>


			<!-- 树联，级联 -->
			<view v-if="item.__config__.jnpfKey == 'treeSelect' || item.__config__.jnpfKey == 'cascader'">
				<treeCascader v-model='formData[item.__vModel__]' :jnpfKey='item.__config__.jnpfKey' :showLabel='item.__config__.showLabel'
				 :required='item.__config__.required' :placeholder="item.placeholder" :label='item.__config__.label' :disabled="item.disabled"
				 :options='options' :vModel='item.__vModel__' :dictionaryType='item.__config__.dictionaryType' :tableModel='item.tableModel' :isId='isId'></treeCascader>
			</view>

			<!-- 省市区选择 -->
			<view v-if="item.__config__.jnpfKey == 'address'">
				<addressSelect v-model='formData[item.__vModel__]' :jnpfKey='item.__config__.jnpfKey' :showLabel='item.__config__.showLabel'
				 :required='item.__config__.required' :placeholder="item.placeholder" :label='item.__config__.label' :disabled="item.disabled"
				 :vModel='item.__vModel__'></addressSelect>
			</view>


			<!-- 日期范围 -->
			<view v-if="item.__config__.jnpfKey == 'dateRange'">
				<rangeTime :item='item' v-model='formData[item.__vModel__]' :showLabel='item.__config__.showLabel' :required='item.__config__.required'
				 :placeholder="item.placeholder" :label='item.__config__.label' :disabled="item.disabled"></rangeTime>
			</view>


			<!-- 系统自动生成的控件 -->
			<view>
				<view v-if="item.__config__.jnpfKey == 'billRule' || item.__config__.jnpfKey == 'createUser' || item.__config__.jnpfKey == 'currDept' || item.__config__.jnpfKey == 'createTime' || item.__config__.jnpfKey == 'modifyUser' || item.__config__.jnpfKey == 'modifyTime' || item.__config__.jnpfKey == 'currPosition' || item.__config__.jnpfKey == 'currOrganize'">
					<autoGenerate v-model="formData[item.__vModel__]" :disabled="item.disabled" :jnpfKey="item.__config__.jnpfKey"
					 :placeholder="item.placeholder" :required='item.__config__.required' :showLabel='item.__config__.showLabel'
					 :label='item.__config__.label'></autoGenerate>
				</view>
			</view>

			<!-- 其他 -->
			<view>
				<!-- 文本框 -->
				<view scroll-y="true" v-if="item.__config__.jnpfKey == 'JNPFText'">
					<JNPFText :textStyle='item.textStyle' :label='item.__config__.label' :defaultValue='item.__config__.defaultValue' :showLabel='item.__config__.showLabel' :Width='item.style'></JNPFText>
				</view>
				<!-- 分组标题 -->
				<view v-if="item.__config__.jnpfKey == 'groupTitle'">
					<groupTitle :content='item.content' :showLabel='item.__config__.showLabel' :label='item.__config__.label'></groupTitle>
				</view>

				<!-- 评分 -->
				<view v-if="item.__config__.jnpfKey == 'rate'">
					<JNPFRate :showLabel='item.__config__.showLabel' :label='item.__config__.label' :disabled="item.disabled" v-model="formData[item.__vModel__]"
					 :max='item.max' :readonly='item.readonly' :allowHalf='item.allowHalf' :required='item.__config__.required'></JNPFRate>
				</view>

				<!-- 开关 -->
				<view v-if="item.__config__.jnpfKey == 'switch'">
					<JNPFSwitch :vModel='item.__vModel__' v-model="formData[item.__vModel__]" :disabled="item.disabled" :required='item.__config__.required'
					 :showLabel='item.__config__.showLabel' :label='item.__config__.label'></JNPFSwitch>
				</view>

				<!-- slider滑块还没好 -->
				<view v-if="item.__config__.jnpfKey == 'slider'">
					<JNPFSlider :min="item.min" :max="item.max" :step="item.step" v-model="formData[item.__vModel__]" :disabled="item.disabled"
					 :required='item.__config__.required' :showLabel='item.__config__.showLabel' :label='item.__config__.label'
					 :vModel='item.__vModel__'></JNPFSlider>
				</view>
			</view>

			<!-- 卡片 -->
			<view v-if="item.__config__.jnpfKey == 'card'" class="uni-flex-column" style="margin-bottom: 20rpx; width: 100%;height: 100%;background-color: #FFFFFF; padding: 20rpx 20rpx;border: 1px dashed #E3E3E5;">
				<view class="labelSty border-bottom-E3E3E5">
					<label for="">{{item.__config__.label}}</label>
				</view>
				<formControl v-for="(card, cardIndex) in item.__config__.children" :key="cardIndex" :item='card' :formData="formData"/>
			</view>

			<!-- 上传图片 -->
			<view v-if="item.__config__.jnpfKey == 'uploadImg'">
				<JNPFUpload :required='item.__config__.required' :showLabel='item.__config__.showLabel' :label='item.__config__.label'
				 :vModel='item.__vModel__' v-model="formData[item.__vModel__]" :fileSize='item.fileSize' :limit='item.limit'></JNPFUpload>
			</view>

			<!-- 子表 -->
			<view v-if="item.__config__.jnpfKey == 'table'" style="margin-bottom: 20rpx;">
				<childTable :item='item' :value="formData[item.__vModel__]" :options='options' :isId='isId' :scanType='scanType'/>
			</view>
		</view>
	</view>
</template>

<script>
	
	import JNPFText from '@/components/JNPFText/JNPFText.vue'
	import groupTitle from '@/components/groupTitle/groupTitle.vue'
	import staticSelect from '@/components/staticSelect/staticSelect.vue'
	import treeCascader from '@/components/treeCascader/treeCascader.vue'
	import rangeTime from '@/components/range-picker/rangeTime.vue'
	import addressSelect from '@/components/addressSelect/addressSelect.vue'
	import comSelect from '@/components/comSelect/comSelect.vue'
	import depSelect from '@/components/depSelect/depSelect.vue'
	import userSelect from '@/components/userSelect/userSelect.vue'
	import posSelect from '@/components/posSelect/posSelect.vue'
	import ymTextarea from '@/components/ym-Textarea/ym-Textarea.vue'
	import comInput from '@/components/comInput/comInput.vue'
	import dateTime from '@/components/dateTime/dateTime.vue'
	import autoGenerate from '@/components/autoGenerate/autoGenerate.vue'
	import JNPFSlider from '@/components/JNPFSlider/JNPFSlider.vue'
	import JNPFSwitch from '@/components/JNPFSwitch/JNPFSwitch.vue'
	import JNPFRate from '@/components/JNPFRate/JNPFRate.vue'
	import JNPFUpload from '@/components/JNPFUpload/JNPFUpload.vue'
	import childTable from '@/components/childTable/childTable.vue'
	export default {
		components: {
			
			staticSelect,
			treeCascader,
			rangeTime,
			addressSelect,
			comSelect,
			depSelect,
			userSelect,
			posSelect,
			ymTextarea,
			comInput,
			dateTime,
			autoGenerate,
			JNPFSlider,
			JNPFSwitch,
			JNPFText,
			groupTitle,
			JNPFRate,
			JNPFUpload,
			childTable
		},
		name: 'formControl',
		props: {
			item: {
				type: Object,
				default () {
					return {}
				}
			},
			formData: {
				type: Object,
				default () {
					return {}
				}
			},
			options:{
				type: Array,
				default () {
					return [{fullName:'默认一',id:'1'},{fullName:'默认二',id:'2'}]
				}
			},
			isId:{
				type:Boolean,
				default () {
					return false
				}
			},
			scanType:{
				type:Boolean,
				default () {
					return false
				}
			},
		},
		data() {
			return {
				tableVmodel: [],
				controlProerty: { //控件属性
					maxlength: 50,
				},
				
			}
		},
		methods: {
			
		}
	}
</script>

<style>

</style>
